//
//  MWTabBarController.m
//  XiRan-iOS
//
//  Created by Richfit on 2019/10/10.
//  Copyright © 2019 Wood. All rights reserved.
//

#import "MWTabBarController.h"
#import "MWNavigationController.h"
#import "MWHomeController.h"
#import "ShowRoomViewController.h"
#import "MWShopController.h"
#import "MWApplicationController.h"
#import "MWMineController.h"
#import "MWTreeSeedController.h"

#import "MWPhoneLoginController.h"

#import "HSFTabBarController.h"

@interface MWTabBarController ()

@end

@implementation MWTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupChildController];
}

- (void)setupTabBarStyle {
    // 正常态文字属性
    NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
    [normalAttrs setObject:[UIFont systemFontOfSize:12] forKey:NSForegroundColorAttributeName];
    [normalAttrs setObject:MWHexColor(@"#666666") forKey:NSForegroundColorAttributeName];
    
    // 选中态文字属性
    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
    [selectedAttrs setObject:[UIFont systemFontOfSize:12] forKey:NSForegroundColorAttributeName];
    [selectedAttrs setObject:MWHexColor(@"#333333") forKey:NSForegroundColorAttributeName];
    
    [[UITabBarItem appearance] setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
    //    [[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, -5)];
    
    // 背景属性
    [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
    [UITabBar appearance].translucent = NO;
}

- (void)setupChildController {

}

- (void)addChildController:(UIViewController *)controller
                     title:(NSString *)title
                     image:(NSString *)image
             selectedImage:(NSString *)selectedImage {
    
    MWNavigationController *navController = [[MWNavigationController alloc] initWithRootViewController:controller];
    
    navController.tabBarItem.title = title;
    navController.tabBarItem.image = [UIImage imageNamed:image];
    navController.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    [self addChildViewController:navController];
}

@end
